<%--
 *  File:    HospitalSummaryForPop.jsp
 *  @Author: banshang
 *  Date:    2010/07/07
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<% 
  	Category cat = Category.getInstance("jsp.StandardDeptSummaryForPop"); 

  //init param
  String strModuleName = "ERM";
  String privilegeCode = "all";
  String contextPath = request.getContextPath();

  String strTableName = "v_dictionary";
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>HospitalSummaryForPop</title>
<PageFlow:CheckPageFlow pageName="p_standarddeptsummaryporpop"/>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
%>

<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script>
function clickRow(value,name)
{
  document.cform.deptname.value = name;
  document.cform.deptvalue.value = value;
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "StandardDeptSummaryForPop.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
function closeWindow(){
	var depatname = document.cform.deptname.value;
	var deptcode = document.cform.deptvalue.value;
	opener.setDept(deptcode,depatname);
	window.close();
}

</script>
</head>
<body>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_standarddeptsummaryporpop">
	<input type="hidden" name="actionname">
	<custom:hidden property="status"/>
   <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0">  
         <%@ include file="/inc/SummarySearch.inc" %>
       </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
         <tr  class="deepblue-left"> 
            <td width="3%" class="title_center">&nbsp;</td>
            <!-- 
            <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','typevalue')"><%= label.getLabelName("L_Status") %></a></td>
             -->
            <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','typename')"><%= label.getLabelName("L_Standard_BusinessType") %></a></td>
         </tr>
         <%
             int j = 0;
             String strClassType = new String(); 
             Integer nDefaultId = new Integer(-1);  
             String nDefaultName = "";
             String nDefaultTypeName = "";
             //String nDefaultCode = "";
             Integer nDefaultValue = new Integer(-1); 
             boolean bHasChecked = false;
             
          %>
          <logic:iterate id="summary" collection="<%= totalsummary %>">                      
         <%
            HashMap summaryMap = (HashMap)pageContext.getAttribute("summary");
            if(summaryMap == null) summaryMap = new HashMap();
            String strIsChecked = new String("");
            
            if(j%2 == 1){
              strClassType = "td-listrom";             
            }else{                    
              strClassType = "";
            }
            
            Integer currentid = (Integer)summaryMap.get("hospitalid");
            if(currentid == null) currentid = new Integer("-1"); 
            
            if(!bHasChecked){
	              strIsChecked = "Checked";                       
	              bHasChecked = true;
	              nDefaultName = (String)summaryMap.get("typename");
	              nDefaultTypeName= (String)summaryMap.get("typename");
	              //System.out.println(nDefaultName+"-----------");
	              //nDefaultCode = (String)summaryMap.get("typename");
	              nDefaultValue = (Integer)(summaryMap.get("typevalue"));
	              nDefaultId = currentid;
	        }       
            j++;     
          %>
           <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:radiotrue('radio<%=JspHelper.filterNull(j)%>');clickRow('<custom:write property="typevalue" name="summary"/>','<custom:write property="typename" name="summary"/>')" class="<%=JspHelper.filterNull(strClassType)%>">
            <td>
              <input class="normalradio" id="radio<%=JspHelper.filterNull(j)%>" type="radio" name="radio" <%=JspHelper.filterNull( strIsChecked)%>>
            </td>
            <!-- 
            <td>&nbsp;<custom:write property="typevalue" name="summary"/></td>
            <td>&nbsp;<custom:write property="typename" name="summary"/></td>
             -->
            <td class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( summaryMap.get("typename") )%></td>
          </tr>
          </logic:iterate>
          <%//---------------set default value-------------------- %>
          <input type="hidden" name="deptvalue" value="<%=JspHelper.filterNull( nDefaultValue)%>"/>
		  <input type="hidden" name="deptname" value="<%=JspHelper.filterNull( nDefaultName )%>"/>
		  <input type="hidden" name="typename" value="<%=JspHelper.filterNull( nDefaultTypeName )%>"/>
      <% //--------------------------------------  flipping page --%>
      <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <tr> 
          <td class="td_center">
            <a onclick="closeWindow()"><custom:button type="1" label="L_Ok" imgsrc="delete.gif" border="0" style="width:60"/></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </form>
</table>
</body>
</html>